package com.jin290.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.jin290.mqlibrary.CourseActivity;
import com.jin290.mqlibrary.SPUtils;

public class MainActivity extends AppCompatActivity {
    private Button btn_ok;
    String course = "语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文," +
            "数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学";

    String week = "--:--,06:00~06:05,13:00~13:05,22:00~22:05,17:00~17:05,12:00~12:05,00:00~00:00,00:00~00:00";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btn_ok = (Button) findViewById(R.id.btn_ok);
        btn_ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (SPUtils.getAll(MainActivity.this).get("course") != null) {
                    course = SPUtils.getAll(MainActivity.this).get("course").toString();
                    week = SPUtils.getAll(MainActivity.this).get("week").toString();
                }
                Intent intent = new Intent(MainActivity.this, CourseActivity.class);

                intent.putExtra("course", course);
                intent.putExtra("week", week);
                startActivityForResult(intent,10086);

            }
        });


    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        super.onActivityResult(requestCode, resultCode, data);

        if(resultCode==10086)
        {
            course=data.getStringExtra("course");
            week=data.getStringExtra("week");
            System.out.println("返回的数据是"+course);

        }

    }
}
